#include "net/rpc/rpc.h"
#include <float.h>

void RPC::Reset() {
  deadline_ = FLT_MAX;
  status_ = PENDING;
}

string RPC::ErrorText() const {
  if (status_ == DEADLINE_EXCEEDED) {
    return "DEADLINE EXCEEDED";
  } else if (status_ == CANCELLED) {
    return "CANCELLED";
  }
  return "";
}

bool RPC::Failed() const {
  return status_ != PENDING && status_ != SUCCEED;
}

void RPC::StartCancel() {}
void RPC::SetFailed(const string&) {}

bool RPC::IsCanceled() const {return status_ == CANCELLED;}
void RPC::NotifyOnCancel(Closure*) {}
  
RPC::RPC() : status_(PENDING), deadline_(FLT_MAX) {
}

void RPC::set_deadline(float deadline) {
  deadline_ = deadline;
}

RPC::RpcStatus RPC::status() {
  return status_;
}
  
void RPC::SetStatus(RpcStatus status) {
  status_ = status;
}
